package com.study.mq.kafka.interceptor;

import org.apache.kafka.clients.producer.ProducerInterceptor;
import org.apache.kafka.clients.producer.ProducerRecord;
import org.apache.kafka.clients.producer.RecordMetadata;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.util.Map;

/**
 * @author ysy
 * @version 1.0
 * @Title: MyConsumerInterceptor
 * @Note  自定义生产端拦截器
 * <br><b>PackageName:</b> com.study.mq.kafka.interceptor
 * <br><b>ClassName:</b> '
 * <br><b>Date:</b>
 */
public class MyProducerInterceptor implements ProducerInterceptor {

    private static final Logger logger = LoggerFactory.getLogger(MyProducerInterceptor.class);
    /**
     * @Author ysy
     * @Description 发送前的处理
     * @Date 17:43
     * @Param
     * @return
     **/
    @Override
    public ProducerRecord onSend(ProducerRecord record) {
        logger.info("监测到消息被发送：{}", record.toString());
        return null;
    }

    /**
     * @Author ysy
     * @Description  应答前、消息发送失败时执行
     * @Date 17:45 [metadata, exception]
     * @Param 
     * @return void
     **/
    @Override
    public void onAcknowledgement(RecordMetadata metadata, Exception exception) {

    }

    @Override
    public void close() {

    }

    @Override
    public void configure(Map<String, ?> configs) {

    }
}
